<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * -----------------------------------------------------
 *
 * manage Subscribe
 *
 * @package     manage
 * @subpackage  
 * @category    Subscribe -  预约管理
 * @author      ChenFu
 * @since       2015-7-7 version 1.0
 * -----------------------------------------------------    
 */
class Subscribe extends CI_Controller{
	public function __construct(){
		parent::__construct();
		$this->load->helper(array('form', 'url'));
	  	$this->load->library('form_validation'); // 表单验证类
		$this->load->model('subscribe_model','subscribe');      // 加载订单模型
		$this->load->model('region_model','region');      // 加载地区模型
		check_login(); // 检查是否登录
	}

	/**
	 * 预约列表
	 * @return [type] [list]
	 */
	public function index()
	{
		$total = $this->subscribe->get_num_rows();

		if($total != 0){
			// 加载分页类
			$arr = array('page_total_num' => $total,'every_page_num'=>20,'page_url_name'=>'page_id');
			$this->load->library('page',$arr);
			$data['pager']	  = $this->page->pages_all();
			$data['arr'] 	  = $this->subscribe->get_all_data_and_page($this->page->limit);
		}else{
			$data['error'] = '暂无预约!';
		}

		$this->load->view('admin/subscribe/index',$data);
	}


	public function search(){
		$total = $this->subscribe->get_num_rows($_GET['product'],$_GET['status']);

		if($total != 0){
			// 加载分页类
			$arr = array('page_total_num' => $total,'every_page_num'=>20,'page_url_name'=>'page_id');
			$this->load->library('page',$arr);
			$data['pager']	  = $this->page->pages_all();

			$data['arr'] 	  = $this->subscribe->get_all_data_and_page_by_where($this->page->limit2,$_GET['product'],$_GET['status']);
		}else{
			$data['error'] = '暂无预约!';
		}
		$this->load->view('admin/subscribe/index',$data);
	}

	/**
	 * [update 更新数据]
	 * @return [type] [description]
	 */
	public function update(){
		$_update = $this->input->post();

		if($this->subscribe->update($_update,$_GET['id'])){
			exit('ok');
		}else{
			exit('no');
		}
	}


	/**
	 * [info 详情]
	 * @return [type] [description]
	 */
	public function info(){
		$info = $this->subscribe->get_a_data_by_id($_GET['id']);
		$this->load->view('admin/subscribe/info',compact("info"));
	}



}